package com.lingxu.module.risk.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lingxu.base.common.api.vo.Result;
import com.lingxu.module.database.entity.TModel;
import com.lingxu.module.risk.service.RiskService;
import com.lingxu.module.risk.vo.JsonFieldsVo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/risk")
public class RiskController {

    @Resource
    private RiskService riskService;

    @GetMapping("/problem-group")
   public Result problemGroup(@RequestParam("modelId") String modelId,
                              @RequestParam("pageNum")Integer pageNum,
                              @RequestParam("pageSize")Integer pageSize,
                              @RequestParam("keyword") String keyword){
        return riskService.queryProblemGroupByModelId(modelId,pageNum,pageSize,keyword);
    }
    @PostMapping("/getDetils")
    public Result getDetils (@RequestBody JsonFieldsVo vo) {
        return riskService.getDetils(vo);
    }
    @GetMapping("/getModel")
    public Page<TModel> getModel(
                                 @RequestParam("name")String name,
                                 @RequestParam("topcategory")String topcategory,
                                 @RequestParam("secondcategory")String secondcategory,
                                 @RequestParam("projectName")String projectName,
                                 @RequestParam("companyName")String companyName) {
        return riskService.getModel(name,topcategory,secondcategory,projectName,companyName);
    }
    /**
     * 核查是否为问题
     */
    @PostMapping("/chackIsIssue")
    public Result chackIsIssue(
            @RequestParam("originalTableName") String originalTableName,
            @RequestParam("isIssue") int isIssue,
            @RequestBody Map<String, Object> groupFields) {

        return Result.ok(riskService.chackIsIssue(originalTableName, groupFields, isIssue));
    }

    /**
     * 已核查查询接口/已处理/未处理查询接口
     * @param modelId
     * @param pageNum
     * @param pageSize
     * @return
     */

    @GetMapping("/problem-group-chack")
    public Result problemGroupChack(@RequestParam("modelId") String modelId,
                                    @RequestParam("pageNum")Integer pageNum,
                                    @RequestParam("pageSize")Integer pageSize,
                                    @RequestParam("isDeal")String isDeal,
                                    @RequestParam("keyword") String keyword){
        return riskService.problemGroupChack(modelId,pageNum,pageSize,isDeal,keyword);
    }

    /**
     * 督办  未完成
     */
    @GetMapping("/notComplete")
    public Result notComplete(@RequestParam("modelId") String modelId,
                                    @RequestParam("pageNum")Integer pageNum,
                                    @RequestParam("pageSize")Integer pageSize,
                                    @RequestParam("keyword") String keyword){
        return riskService.notComplete(modelId,pageNum,pageSize,keyword);
    }

    /**
     * 修改督办状态
     * @param vo
     * @return
     */
    @PostMapping("/updateIsSupervise")
    public Result<Integer> updateIsSupervise (@RequestBody JsonFieldsVo vo){
        return riskService.updateIsSupervise(vo);
    }


    /**
     * 已督办页面查询
     */
    @GetMapping("/alreadySupervise")
    public Result alreadySupervise(@RequestParam("modelId") String modelId,
                              @RequestParam("pageNum")Integer pageNum,
                              @RequestParam("pageSize")Integer pageSize,
                              @RequestParam("keyword") String keyword){
        return riskService.alreadySupervise(modelId,pageNum,pageSize,keyword);
    }



    /**
     * 问题管理分组查询页面
     * @param pageNum
     * @param pageSize
     * @return
     */
    @GetMapping("/getModel-chack")
    public Page<Map<String, Object>> getModelChack(@RequestParam("pageNum")Integer pageNum,
                                                   @RequestParam("pageSize")Integer pageSize,
                                                   @RequestParam("name")String name,
                                                   @RequestParam("topCategory")String topCategory,
                                                   @RequestParam("secondCategory")String secondCategory) {
        return riskService.getModelChack(pageNum,pageSize,name,topCategory,secondCategory);
    }

    /**
     * 问题管理页面-模型关联工作流接口
     * @param tModel
     * @return
     */
    @PostMapping("/updateWorkKeyById-chack")
    public Result updateWorkKeyById(TModel tModel) {
        return riskService.updateWorkKeyById(tModel);
    }
}
